package com.huangtang.pc.config;

import com.huangtang.pc.interceptor.TestInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author sunjf
 * @date 2024/01/0
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    private final TestInterceptor testInterceptor;

    public WebConfig(TestInterceptor testInterceptor) {
        this.testInterceptor = testInterceptor;
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        String[] excludes = new String[] {"/swagger-ui.html","/doc.html", "/swagger-resources/**", "/webjars/**", "/error"};
        registry.addInterceptor(testInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns(excludes);
    }
}
